// LibraryService.java (接口)
package Object.work.service;

import Object.work.exception.BookNotFoundException;
import Object.work.exception.DuplicateBookException;
import Object.work.exception.InvalidOperationException;
import Object.work.exception.UserNotFoundException;
import Object.work.model.LibraryItem;
import Object.work.model.User;

import java.util.List;

public interface LibraryService {
    // 图书CRUD
    void addBook(LibraryItem item) throws DuplicateBookException;
    LibraryItem getBookById(String id) throws BookNotFoundException;
    void updateBook(String id, LibraryItem newItem) throws BookNotFoundException, DuplicateBookException;
    void deleteBook(String id) throws BookNotFoundException;
    List<LibraryItem> getAllBooks();
    List<LibraryItem> searchBooksByTitle(String keyword);

    // 用户CRUD
    void addUser(User user) throws DuplicateBookException;
    User getUserById(String id) throws UserNotFoundException;
    void updateUser(String id, User newUser) throws UserNotFoundException, DuplicateBookException;
    void deleteUser(String id) throws UserNotFoundException;
    List<User> getAllUsers();
    List<User> searchUsersByName(String keyword);

    // 借还书
    void borrowBook(String bookId, String userId) throws BookNotFoundException, UserNotFoundException, InvalidOperationException;
    void returnBook(String bookId) throws BookNotFoundException, InvalidOperationException;

    // 显示方法
    void displayAllBooks();
    void displayAllUsers();
    void displayBooks(List<LibraryItem> books);
    void displayUsers(List<User> users);
}